package com.ict.ycwl.user;

import com.auth0.jwt.JWT;
import com.ict.ycwl.user.dao.GroupDao;
import com.ict.ycwl.user.dao.RoleOperationDao;
import com.ict.ycwl.user.dao.UserDao;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class testdemo {
    @Autowired
    private RoleOperationDao roleOperationDao;

    @Autowired
    private GroupDao groupDao;

    @Autowired
    private UserDao userDao;

    @Test
    public void testtoken() {
//        QueryWrapper<Group> wrapper = new QueryWrapper<>();
//        wrapper.eq("group_name","123");
//        Group group = groupDao.selectOne(wrapper);

//        QueryWrapper<User> wrapper = new QueryWrapper<>();
//        wrapper.eq("user_name","ycwl");
//        User user = userDao.selectOne(wrapper);

//        String de = "e10adc3949ba59abbe56e057f20f883e";
//        String password = "123456";
//        System.out.println(MD5Util.string2MD5(password));

//        LambdaQueryWrapper<User> lambdaQueryWrapper = new LambdaQueryWrapper<>();
//        lambdaQueryWrapper.eq(User::getWorkNumber,"ycwl");
//
//        QueryWrapper<User> wrapper = new QueryWrapper<>();
//        wrapper.select("user_name","position","work_number");
//        List<User> users = userDao.selectList(wrapper);
//
//        Page<User> page = new Page<>(2,2);
//        IPage<User> iPage = userDao.selectPage(page,wrapper);
//        System.out.println(iPage);
//
//        String password = "YC20231020wl";
//        System.out.println(MD5Util.string2MD5(password));

        String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJMb2dpbk5hbWUiOiJ4aWFvbGkiLCJwYXNzd29yZCI6ImUxMGFkYzM5NDliYTU5YWJiZTU2ZTA1N2YyMGY4ODNlIiwid29ya051bWJlciI6Imh0MDAyIiwicm9sZUlkIjo0LCJ1c2VyTmFtZSI6IuWwj-adjiIsInVzZXJJZCI6IjQifQ.TqUbrNCYgS48qYicC8Ls7JGzi4w_2NLu4y6jWgeEdVg";
        Long roleId = JWT.decode(token).getClaim("roleId").asLong();
        System.out.println(roleId);



    }
}
